import { RouteRecordRaw } from 'vue-router'
import Layout from '@/layout/index.vue'

export const dataRouterMenu: Array<RouteRecordRaw> = [
  {
    path: '/data',
    name: 'Node',
    component: () => import('@/views/data/index.vue'),
    meta: { title: '顶点数据', hidden: false },
    children: [
      {
        path: 'person',
        component: () => import('@/views/data/components/PersonData.vue'),
        name: 'PersonData',
        meta: { title: '人员表', icon: 'dashboard', affix: true },
      },
      {
        path: 'movie',
        component: () => import('@/views/data/components/MovieData.vue'),
        name: 'MovieData',
        meta: { title: '电影表', icon: 'dashboard', affix: true },
      },
    ],
  },
  {
    path: '/data',
    name: 'Edge',
    component: () => import('@/views/data/index.vue'),
    meta: { title: '关系数据', hidden: true },
    children: [
      {
        path: 'work',
        component: () => import('@/views/data/components/WorkData.vue'),
        name: 'WorkData',
        meta: { title: '工作表', icon: 'dashboard', affix: true },
      },
    ],
  },
]

const getRoutes  = []
dataRouterMenu.forEach(d => {
  getRoutes.push(...(d.children || []))
})

export const dataRouter: RouteRecordRaw =   {
  path: '',
  component: Layout,
  children: [
    {
      path: '/data',
      name: 'Data',
      redirect: '/data/person',
      component: () => import('@/views/data/index.vue'),
      meta: { title: '数据管理' },
      children: getRoutes
    },
  ],
}

// export default dataRouter
